package com.liwy3.task.demo;

import com.dmall.dispatcher.sdk.SchedulerStarter;
import com.dmall.dispatcher.sdk.service.ITaskService;
import com.dmall.dispatcher.sdk.util.IBasicExecuteContext;
import com.dmall.monitor.sdk.MonitorConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

import java.util.HashSet;
import java.util.Set;

/**
 * @author weiye.li
 * @date 2022/12/5
 */
@Configuration
@DependsOn("demoTask")
public class TaskConfig {

    @Autowired
    private Set<ITaskService> taskSets;

    @Bean(value = "monitorConfig", initMethod = "monitorInit")
    public MonitorConfig monitorConfig() {
        return new MonitorConfig("dmall-middlelayer-dcp", "dmall-middlelayer-dcp-task",
                "http://testds.dmc.api.inner-dmall.com/", true);
    }

    @Bean(initMethod = "start")
    public SchedulerStarter schedulerStarter() {

        return new SchedulerStarter("4BCAEFDA-9300-4E19-A2D5-B4B2F42876CB", taskSets, "rdamp.ddc.dmall.com");
    }

}
@Component
class DemoTask implements ITaskService {
    @Override
    public void execute(String s, IBasicExecuteContext iBasicExecuteContext) {
        System.out.println("测试demoTask");
    }
}
